package com.alex.dao;

import com.alex.pojo.User;
import com.alex.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

// 将 UserDao 接口映射到 mapper 配置文件中后, 将不再需要编写impl实现类,由mybatis通过反射自动生成实现类
public class UserDaoImpl implements UserDao {

    @Override
    public User getUser(int id) {
        return null;
    }

    @Override
    public List<User> getUserList() {
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        List<User> students = sqlSession.selectList("com.com.alex.dao.UserMapper.getUserList");
        sqlSession.close();
        return students;
    }
}
